package com.medical.medical.service.doctorManageService;

import com.medical.medical.entity.Department;
import com.medical.medical.entity.Doctor;
import com.medical.medical.mapper.DoctorManageMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import javax.print.Doc;
import java.util.List;

/**
 * @ClassName doctorManageServiceImpl
 * @Description 医生信息管理逻辑层
 * @Author 皮皮虾
 * @Date 2022/9/14 11:41
 * @Version 1.0
 */
@Service
@Transactional
@Slf4j
public class DoctorManageServiceImpl implements DoctorManageService{
    @Resource
    private DoctorManageMapper doctorManageMapper;

/*    *//**
     * @description: 查询科室详细信息
     * @author: 皮皮虾
     * @date: 2022/9/14
     * @param
     * @return:
     *//*
    public Department listDepartment(String departmentId){
        Department department = doctorManageMapper.listDepartment(departmentId);
        if (department!=null){
            log.info("科室信息查询成功！");
        return department;
        }else {
            log.info("科室信息查询失败！");
            return null;
        }
    }*/


    /**
     * @description: 查询所有医生
     * @author: 皮皮虾
     * @date: 2022/9/14
     * @param
     * @return:
     */
    @Autowired
    public List<Doctor> allDoctor(){
        List<Doctor> doctors = doctorManageMapper.allDoctor();
        if (doctors!=null) {
            log.info("科室医生查询成功！");
            return doctors;
        }else {
            log.info("科室医生查询失败！");
            return null;
        }
    }

    /**
     * @description:根据医生id查询医生详细信息
     * @author: 皮皮虾
     * @date: 2022/9/14
     * @param
     * @return:
     */

    public Doctor listDoctor(String dId){
        Doctor doctor = doctorManageMapper.listDoctor(dId);
        if (doctor!=null) {
            log.info("医生信息查询成功！");
            return doctor;
        }else {
            log.info("医生信息查询失败！");
            return null;
        }
    }

    /**
     * @description:添加医生信息
     * @author: 皮皮虾
     * @date: 2022/9/14
     * @param
     * @return:
     */

    public int addDoctor(String dName,
                         String dAge,
                         String dGender,
                         String dDesc,
                         String dPost,
                         String registrationFee,
                         String dHospital,
                         String dDepartment,
                         String dAccount,
                         String phone,
                         String password
                         ){
        int i = doctorManageMapper.addDoctor(dName, dAge, dGender, dDesc, dPost, registrationFee, dHospital, dDepartment,dAccount,phone,password);
        if (i!=0) {
            log.info("医生添加成功！");
            return i;
        }else {
            log.info("医生添加失败！");
            return 0;
        }
    }

    /**
     * @description:根据医生id修改医生信息
     * @author: 皮皮虾
     * @date: 2022/9/14
     * @param
     * @return:
     */

    public int reviseDoctor(String dName,
                            String dId,
                            String dAge,
                            String dGender,
                            String dDesc,
                            String dPost,
                            String dDepartment,
                            String dHospital) {
        int i = doctorManageMapper.reviseDoctor(dName,dId, dAge, dGender,dDesc,dPost,dDepartment, dHospital);
        if (i!=0) {
            log.info("医生信息修改成功！");
            return i;
        }else {
            log.info("医生信息修改失败！");
            return 0;
        }
    }

    /**
     * @description:根据医生id删除医生信息
     * @author: 皮皮虾
     * @date: 2022/9/14
     * @param
     * @return:
     */

    public int delDoctor(String dId){
        int i = doctorManageMapper.delDoctor(dId);
        if (i!=0) {
            log.info("医生删除成功！");
            return i;
        }else {
            log.info("医生删除失败！");
            return 0;
        }
    }

}